//
//  CountPresenter.m
//  DebugDemo
//
//  Created by XFB on 2019/5/7.
//  Copyright © 2019 ZhouCheng. All rights reserved.
//

#import "CountPresenter.h"

@interface CountPresenter ()
{
    id <CountModelProtocol> _countModel;
    id <CountViewProtocol> _countView;
}

@end

@implementation CountPresenter

- (CountPresenter *)initWithModel:(id<CountModelProtocol>)countModel
                        countView:(id<CountViewProtocol>)countView
{
    if (self = [super init]) {
        _countModel = countModel;
        _countView = countView;
    }
    return self;
}

#pragma mark --- <CountPresenterProtocol>
- (void)getCurrentValue
{
    NSInteger value = [_countModel getCurrentValue];
    [_countView updateCountValue:[NSString stringWithFormat:@"%ld", (long)value]];
}

- (void)increaseCount
{
    NSInteger value = [_countModel getCurrentValue];
    value = value + 1;
    [_countModel setCurrentValue:value];
    [_countView updateCountValue:[NSString stringWithFormat:@"%ld", (long)value]];
}

- (void)decreaseCount
{
    NSInteger value = [_countModel getCurrentValue];
    value = value - 1;
    [_countModel setCurrentValue:value];
    [_countView updateCountValue:[NSString stringWithFormat:@"%ld", (long)value]];
}



@end
